from .celery import app
from order.models import Order
import datetime


@app.task
def update_order():
    """
    订单超过30分钟未付款，删除
    """
    end_time = datetime.datetime.now() - datetime.timedelta(seconds=2)

    Order.objects.filter(is_delete=False, is_show=True, order_status=0, create_time__lt=end_time).update(is_delete=True,
                                                                                                         is_show=False)
    # create_time +30 > end_time
